package com.trinity.orders.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.trinity.common.core.domain.AjaxResult;
import com.trinity.orders.domain.XcOrders;
import com.trinity.orders.domain.XcPayRecord;
import com.trinity.orders.dto.AddManualOrderDto;
import com.trinity.orders.dto.AddOrderDto;
import com.trinity.orders.dto.PayRecordDto;

import java.util.List;
import java.util.Map;

/**
 * 订单信息Service接口
 *
 * @author trinity
 * @date 2023-11-19
 */
public interface IXcOrdersService extends IService<XcOrders> {

    /**
     * 切换项目状态 时 切换关联账单的状态
     * 未开始 --激活-> 进行中
     * 进行中 --暂停-> 未开始
     */
    public void changeStatus( String listId,String status);

    /**
     * 查询订单信息
     *
     * @param id 订单信息主键
     * @return 订单信息
     */
    public XcOrders selectXcOrdersById(String id);

    /**
     * 调取微信下单
     *
     * @param id     订单号
     * @param openid wxid
     * @return er
     */
    public AjaxResult requestPayment(String id, String openid) throws WxPayException;

    public AjaxResult requestPaymentV2(String id, String openid) throws WxPayException;

    public XcOrders getOrderByBusinessId(String businessId);

    /**
     * 查询订单信息列表
     *
     * @param xcOrders 订单信息
     * @return 订单信息集合
     */
    public List<XcOrders> selectXcOrdersList(XcOrders xcOrders);

    public List<XcOrders> selectOrderIdSList(String[] ids);

    /**
     * @param addOrderDto 订单信息
     * @return PayRecordDto 支付交易记录(包括二维码)
     * @description 创建商品订单
     * @author Mr.M
     * @date 2022/10/4 11:02
     */
    public XcOrders createOrder(String userId, AddOrderDto addOrderDto);

    public XcPayRecord createWxOrderPayRecord(XcOrders orders, String openid);

    /**
     * 查询订单状态
     *
     * @param orderNo
     * @param payNo
     * @param tradeState
     * @return
     */
    public AjaxResult pollingOrder(String orderNo, String payNo, String tradeState);


    /**
     * 批量发布订单
     *
     * @param dto 订单集合
     * @return re
     */
    public String release(List<AddOrderDto> dto);

    /**
     * 批量撤回发布订单
     *
     * @param businessId 订单集合
     * @return re
     */
    public String revokeRelease(String businessId);

    public  String revokeReleaseOne(String scheduleId, Long studentId);

    /**
     * @param addOrderDto 订单信息
     * @return PayRecordDto 支付交易记录(包括二维码)
     * @description 创建商品订单 并生成支付ji'l记录
     * @author Mr.M
     * @date 2022/10/4 11:02
     */
    public PayRecordDto createOrderAndPayRecord(String userId, AddOrderDto addOrderDto);

    /**
     * @param addOrderDto 手工单信息
     * @return PayRecordDto
     * @description 创建商品订单
     * @author Mr.M
     * @date 2022/10/4 11:02
     */
    public PayRecordDto createManualOrder(String userId, AddManualOrderDto addOrderDto);

    /**
     * @param addOrderDto 订单信息
     * @return PayRecordDto 支付交易记录(包括二维码)
     * @description 创建商品订单
     * @author Mr.M
     * @date 2022/10/4 11:02
     */
    public PayRecordDto AppcreateOrder(String userId, AddOrderDto addOrderDto) throws WxPayException;

    /**
     * 修改订单信息
     *
     * @param xcOrders 订单信息
     * @return 结果
     */
    public int updateXcOrders(XcOrders xcOrders);

    /**
     * 批量删除订单信息
     *
     * @param ids 需要删除的订单信息主键集合
     * @return 结果
     */
    public int deleteXcOrdersByIds(String[] ids);

    /**
     * 删除订单信息信息
     *
     * @param id 订单信息主键
     * @return 结果
     */
    public int deleteXcOrdersById(String id);

    String cancelOrder(String id) throws WxPayException;

    public AjaxResult refundOrder(Map<String, Object> order);

    /**
     * 手动确认支付
     */
    void manualConf(String orderId, String amount, String currency, String remark);

    /**
     * 判断是否已经有人开始缴费
     */
    boolean hasStudentPaid(String scheduleId);
}
